package com.douyang.controller;


import cn.dev33.satoken.annotation.SaCheckRole;
import com.douyang.dto.GetReviewListDTO;
import com.douyang.dto.UpdateVideoDTO;
import com.douyang.base.expcetion.VideoException;
import com.douyang.base.model.PageResult;
import com.douyang.base.model.Result;
import com.douyang.service.ReviewVideoInfoService;
import com.douyang.vo.ReviewVideoInfoVO;
import com.douyang.vo.VideoAndImageUrlVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/video/reviewer")
@RestController
@SaCheckRole("reviewer")
public class VideoReviewerController {

    @Autowired
    ReviewVideoInfoService reviewVideoInfoService;

    @PostMapping("/getReviewList")
    public Result<PageResult<ReviewVideoInfoVO>>getReviewList(@RequestBody GetReviewListDTO getReviewListDTO) {
        return Result.success(reviewVideoInfoService.getReviewListByReviewer(getReviewListDTO));
    }

    @PostMapping("/updateVideo")
    public Result<String> updateVideo(@RequestBody UpdateVideoDTO updateVideoDTO){
        if(updateVideoDTO.getId()==null || updateVideoDTO.getStatus()==null){throw new VideoException("updateStatus:参数异常");}
        reviewVideoInfoService.updateVideo(updateVideoDTO);
        return Result.success("ok");
    }

    @GetMapping("/getVideoAndImageUrl")
    public Result<VideoAndImageUrlVO> getVideoAndImageUrl(Long id) {
        return Result.success(reviewVideoInfoService.getVideoAndImageUrl(id));
    }
}
